<%@page import="study.top.mydb.Member"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page session="true" %>
<%@ include file="dbcon.jsp" %>


<!DOCTYPE html>
<html lang="ko">
	<%@include file="topHead.jsp"%>
	<%@ include file="topcategory.jsp" %>
<%
	if(mem_seq <= 0) {
		web.goPage("uMemLogin.jsp", "회원만 작성이 가능합니다.");
		return;
	}

	String mem_id = memberItem.getId();
	
%>

	<body>
	<div class="top-tab top-hidden-xs">
		<%@include file="tab.jsp"%>
	</div>
			<div class="container"style="width: 70%">
		
			<div class="page-header">
				<h3>Q&A - <small>궁금한 사항이나 불편한 점을 작성해주세요.</small></h3>
			</div>
			
			<form class="form-horizontal"  id="boardwrite" role="form" action="uBrdQAWriteOk2.jsp" enctype="multipart/form-data" method="post">
				<fieldset>
					
					<!-- 입력양식 -->
					<div class="form-group">
						<label for="title" class="col-md-2 control-label">제목</label>
						<div class="col-md-10">
							<input type="text" class="form-control" id="title" name="title" placeholder="제목을 입력하세요.">
						</div>
					</div>
					<!--// 입력양식 -->
					
					<!-- 입력양식 -->
					<div class="form-group">
						<label for="member_id" class="col-md-2 control-label">작성자</label>
						<div class="col-md-10">
							<input type="text" class="form-control"  placeholder="<%=mem_id%>" disabled="disabled">
						</div>
					</div>
					<!--// 입력양식 -->
										
					<!-- 입력양식 -->
					<div class="form-group">
						<label for="content" class="col-md-2 control-label">내용</label>
						<div class="col-md-10">
							<textarea id="content" name="content" class="form-control ckeditor" rows="5" placeholder="내용을 입력하세요."></textarea>
						</div>
					</div>
					<!--// 입력양식 -->
					
					<!-- 입력양식 -->
					
				
					<div class="form-group">
						<label for="file" class="col-md-2 control-label"></label>
						<div id="fileadd" class="col-md-10">
							
							<button type="button" id="mybtn" class="btn top-btn-custom">이미지 추가</button>
							<button type='button' id='mybtn2' class='btn btn-default'>이미지 삭제</button>
							
							
							
						</div>
					</div>
					<!--// 입력양식 -->
					
					<!-- 입력양식 -->
					<div class="form-group">
						<div class="col-md-offset-4 col-md-8">
							<div class="row">
								<div class="col-xs-3">
									<button type="submit" class="btn top-btn-custom btn-block">저장</button>											
								</div>
								
								
								<div class="col-xs-3">
									<a href="uBrdQAlist.jsp" class="btn btn-default btn-block">취소</a>
								</div>
							</div>
						</div>
					</div>
					<!--// 입력양식 -->
				</fieldset>
			</form>

		</div>
		<div class="top-hidden-xs">
			<%@ include file="topBottom.jsp" %>
		</div>
			
				<!-- Javascript -->
				
				<script src="assets/js/string.js"></script>
				<script src="assets/ckeditor/ckeditor/ckeditor.js"></script>
				<script type="text/javascript">
				
				$(function(){
					
					$('#mybtn').click(function() {
						
						$("#fileadd").append($("<input type='file' class='form-control' id='file' name='file' multiple />"));
						
						//$("#boardwrite").attr('action', 'uBrdQAWriteOk2.jsp');																							
						
					});
					
					$('#mybtn2').click(function(){
						
						
						
						$("#file:last").remove();
						
					});
					
										
					$("#boardwrite").submit(function(){
						
						if (!$("input[name='title']").val()
								.isValue()) {
							alert("제목을 입력하세요.");
							$("input[name='title']").focus();
							return false;
						}
						
						if (!$("input[name='file']").val()
								.isValue()) {
							alert("이미지를 올려주세요.");
							$("input[name='file']").focus();
							return false;
						}
						
						
						
					});
				});
								
				  CKEDITOR.replace( 'content',{
    				
					 uiColor: '#ffffff',
					 toolbar:
    				[				
    				 	['Styles','Format','Font','FontSize'],    				 
      					['Bold','-', 'Italic'],
      					['NumberedList']
    				]
  				});
				
				</script>
												
	</body>
</html>